<template>
	<div>
		<Transfer v-if="userList!==false" :isSearch="props.isNeedSearch" :title="props.title" :list="userListArr" :searchList="userList" :isSearchReturn="isSearchReturn"
			:isH5="true" :isRadio="props.isRadio" :total="props.total" @getMore="handleGetMore"
			@search="handleSearchUser" @submit="submit" @cancel="reset" />
	</div>
</template>
<script lang="ts" setup>
	import { ref, watch, computed } from "../../../adapter-vue";
	import { isPC } from "../../../utils/env";
	import Dialog from "../Dialog/index.vue";
	import Transfer from "../Transfer/index.vue";
	import { sortByFirstLetter } from "../../../utils/checkLogin.js";
	import { ITransferListItem } from "../../../interface";
	const emits = defineEmits(["complete", "search", "getMore"]);

	const props = defineProps({
		isRadio: {
			type: Boolean,
			default: false,
		},
		isNeedSearch: {
			type: Boolean,
			default: false,
		},
		title: {
			type: String,
			default: '',
		},
		// false防止列表有值了 组件没有检测到
		userList: {
			type: [Array, Boolean],
			default: false,
		},
		total: {
			type: Number,
			default: 0,
		}
	})
	//是否显示暂无用户
	const isSearchReturn=computed(() => {
		return !props.userList.length
	}
	);
	//将用户列表变成abc分组的排序
	const userListArr = computed(() => {
		return sortByFirstLetter(props.userList) as Array<ITransferListItem>
	}
	);


	const reset = () => {
		emits('complete', []);
	};


	const submit = (dataList : any) => {
		emits('complete', dataList);
	};

	const handleSearchUser = (userID : string) => {
		emits('search', userID);
	}

	const handleGetMore = () => {
		emits('getMore');
	}
</script>